home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / Sources / src / Amiga / h / amiga.h next >
Encoding:
C/C++ Source or Header  |  1996-09-27  |  11.7 KB  |  467 lines

  1. /* This file is part of the origami distrubution. (Amiga Port)
  2.  *
  3.  * Source code written by Thomas Hadig in September 1991
  4.  * Version : 1.6.92.1, February 1994
  5.  * (C) 1991-94 by Thomas Hadig
  6.  * may be distributed unchanged ! (see copyright notes)
  7.  */
  8.  
  9. #ifndef AMIGA_H
  10. #define AMIGA_H
  11. /*{{{}}}*/
  12. /*{{{  general defines*/
  13. #define _POSIX_PATH_MAX 120
  14. #define STD_BASENAME ".origami"
  15. #define MOUSE_BUTTONS 30
  16. #define RC_BUFFER_SIZE 8192
  17. #define BASENAMEF       ".%s"
  18. #define ORIGAMI_RC_PATH   "S:"
  19.  
  20. /*{{{  directory defines*/
  21. #undef  CURR_DIR
  22. #undef  PREV_DIR
  23. #define CURR_DIR   getcwd(buffer_dir,_POSIX_PATH_MAX)
  24. #define PREV_DIR "/"
  25.  
  26. #define IS_ROOT(s) (!strcmp(s,":"))
  27. /*}}}  */
  28. /*{{{  stat stuff*/
  29. #define S_ISDIR(x)  (x & S_IFDIR)
  30. #define S_ISCHR(x)  (0)
  31. #define S_ISBLK(x)  (0)
  32. #define S_ISREG(x)  (x & S_IFREG)
  33. #define S_ISFIFO(x) (0)
  34.  
  35. #define S_IRUSR     (0)
  36. #define S_IRGRP     (0)
  37. #define S_IROTH     (S_IREAD)
  38. /*}}}  */
  39. /*{{{  passwd defines*/
  40. #define getpwuid(x)    ((struct passwd *)0)
  41. /*{{{  struct passwd*/
  42. struct passwd { char *pw_name; };
  43. /*}}}  */
  44. /*}}}  */
  45. /*}}}  */
  46.  
  47. #ifndef FOLDER
  48. #define boolean int
  49. /*{{{  not dirfold*/
  50. /*{{{  compiler defines (switches for features)*/
  51. /* There are some switches, that enable several features in origami :
  52.  * ASL : will use the asl requester, if asl.library is available
  53.  * PRIORITY : will change origamis priority, when activated (3)
  54.  * AREXX : will enable the arexx port (isn't functional)
  55.  * MOUSY : will enable mouse using
  56.  * MENU  : will enable menus
  57.  * ICONIFY : will enable the inconify feature
  58.  * CUTPASTE : will enable the cut & paste feature
  59.  *
  60.  * There are some switches that define some of the above features :
  61.  * REQUEST : ASL
  62.  * NORMAL : MENU & MOUSY & CUTPASTE
  63.  * BIG1 : REQUEST & NORMAL
  64.  * BIG : BIG1 & ICONIFY
  65.  *
  66.  * VIRTUAL will not be supported
  67.  */
  68.  
  69. #define DOC_MSG           ORIGAMI_RC_PATH
  70. #define KBD_PATH          "S:origami"
  71. #define NOSYSEXIT
  72. #define DEFAULT_NAME      "Origami"
  73. #define DEFAULT_TERM      "AMIGA"
  74. #define PORTER            "Amiga Port by Thomas Hadig.\n"
  75. #define USE_SCRBUFF
  76. #define BLOCK_FLUSH
  77. #define SW_MSG
  78. /*{{{  dir_edit*/
  79. #define DIREDT
  80. #define DC_OPT_F "-s -M \"%s%s%s%s\" -f \"%s\" -F \"%s\" %s %s"
  81. #define DC_OPT_ARG(na,long,ma,noma)                                 \
  82.   bd.f.str.open_f,bd.f.str.file_f,bd.f.str.line_f,bd.f.str.close_f, \
  83.   ma,noma,((long)?"-l":""),na
  84. #define DIR_CMD(name,long,match,nomatch)                     \
  85.   (char*)get_msg                                             \
  86.    ( MSG_ARG_FORMAT,                                         \
  87.      "dirfold "DC_OPT_F,                                     \
  88.      DC_OPT_ARG(name,long,match,nomatch)                     \
  89.    )
  90. #ifdef DIREDT_PATH
  91. # define DIR_CMD2(name,long,match,nomatch)                 \
  92.    (char*)get_msg                                          \
  93.     ( MSG_ARG_FORMAT,                                      \
  94.       DIREDT_PATH PATH_SEP "dirfold "DC_OPT_F,             \
  95.       DC_OPT_ARG(name,long,match,nomatch)                  \
  96.     )
  97. # endif
  98. /*}}}  */
  99.  
  100. #ifdef BIG
  101. #  define BIG1
  102. #  define ICONIFY
  103. #endif
  104. #ifdef BIG1
  105. #  define REQUEST
  106. #  define NORMAL
  107. #endif
  108. #ifdef REQUEST
  109. #  define ASL
  110. #endif
  111. #ifdef NORMAL
  112. #  define MENU
  113. #  define MOUSY
  114. #  define CUTPASTE
  115. #endif
  116. /*}}}  */
  117.  
  118. /*{{{  additional includes*/
  119. #ifdef AREXX
  120. #include <amiga/h/ori_arexx.h>
  121. #endif
  122. #include <exec/types.h>
  123. #include <stdio.h>
  124. /*}}}  */
  125. /*{{{  stdio-stuff*/
  126. #ifndef _OFF_T
  127. #define _OFF_T 1
  128. typedef int off_t;
  129. #endif
  130.  
  131. #define READ            "r"
  132. #define READ_BIN        "r"
  133. #define WRITE           "w"
  134. #define WRITE_BIN       "w"
  135. #define LIST_SEP        ";"
  136. #define LIST_C          ';'
  137. #define LIST_C_1        '\001'
  138. #define OS_NULL_DEVICE  "nil:"
  139. #define NEVER           0
  140. #define RC_OS_EXT_HANDLE(f,i) os_ext_handle(f,i)
  141. /*}}}  */
  142. /*{{{  defines*/
  143. #define SIGWINCH
  144.  
  145. /*{{{  Amiga Arguments*/
  146. #define OWN_ARG_HANDLE nok = handle_amiga_args (optarg);
  147. #define OWN_ARG_USAGE_SHORT \
  148. "\n        [-X S[CREEN][=Width/Height]|W[INDOW]=X/Y/Width/Height|A[REXX][=Portname]]\n       "
  149. #define OWN_ARG_USAGE_LONG \
  150.     "-X S[CREEN][=Width/Height] opens origami on own screen (size w,h)\n"\
  151. "    -X W[INDOW]=X/Y/Width/Height] specifies window size\n"\
  152. "    -X A[REXX][=Portname]\n"
  153. /*}}}  */
  154. /*{{{  mouse and menu defines*/
  155. #define AMIGA_MOUSE_TAG    amiga
  156. #define OS_MOUSE_TAG       AMIGA_MOUSE_TAG
  157. #define AMIGA_MOUSE_NAME   "amiga"
  158. #define OS_MOUSE_NAME      AMIGA_MOUSE_NAME
  159. #define AMIGA_MOUSE_COUNT  MOUSE_BUTTONS
  160. #define OS_MOUSE_COUNT     AMIGA_MOUSE_COUNT
  161. #define AMIGA_MOUSE_NAMES { \
  162.   "LMBU", "RMBU", "MMBU", "LMBD", "MMBD", \
  163.   "S-LMBU", "S-RMBU", "S-MMBU", "S-LMBD", "S-MMBD", \
  164.   "C-LMBU", "C-RMBU", "C-MMBU", "C-LMBD", "C-MMBD", \
  165.   "A-LMBU", "A-RMBU", "A-MMBU", "A-LMBD", "A-MMBD", \
  166.   "L-LMBU", "L-RMBU", "L-MMBU", "L-LMBD", "L-MMBD", \
  167.   "R-LMBU", "R-RMBU", "R-MMBU", "R-LMBD", "R-MMBD"}
  168. #define OS_MOUSE_TAG_MOUSE_UP(a) ((a%5)<3)
  169. #define OS_MOUSE_NAMES     AMIGA_MOUSE_NAMES
  170. #define OS_MOUSE_LG        0
  171. #define OS_MOUSE_CODE      ""
  172. #define DEFAULT_MOUSE      "amiga"
  173. /*}}}  */
  174. /*{{{  screen defines*/
  175. #define Off_X 4          /* defines start position X-coordinate  */
  176. #define Off_X_Right 19   /* defines space right in pixels */
  177. #define Off_Y_Bottom 3   /* .. bottom */
  178. /*}}}  */
  179. /*{{{  stdio defines*/
  180. #define oputs(a)  eputs(a)
  181. #define oflush    FlushOneLine();
  182. /*}}}  */
  183. /*{{{  get-key defines*/
  184. #define PSEUDO_ABORT_KEY 0x9C
  185. #define CSI 0x9B
  186. #define buffer_keys_max  200
  187. #define CSI_RAW_KEY 69
  188. #define CSI_NUMBER_PAD 70
  189. #define CSI_MENU_PICK 71
  190. #ifdef CUTPASTE
  191.   /*{{{  cut & paste stuff*/
  192. #  define CUPA_TEXT_LEN    256
  193.   struct cupa
  194.    {
  195.     struct cupa *Next;
  196.     int cur_pos;
  197.     char text[CUPA_TEXT_LEN];
  198.    };
  199.   /*}}}  */
  200. #endif
  201. /*}}}  */
  202. /*{{{  GETMSG_C*/
  203. #ifdef GETMSG_C
  204. #  define I_SHELL_C
  205. #endif
  206. /*}}}  */
  207. /*{{{  KEYBIND_C*/
  208. #ifdef KEYBIND_C
  209. #  undef strlen
  210. #  define SIGQUIT   SIGINT
  211. #  define SIGHUP    SIGINT
  212. #  define I_AMIGAFILEIO_C
  213. #  define REF_TMP_FILE "T:kbrefXXXXXX"
  214.    char buffer_dir[_POSIX_PATH_MAX];
  215. #endif
  216. /*}}}  */
  217. /*{{{  FINDS_C*/
  218. #ifdef FINDS_C
  219. #  define I_SIGNALS_C
  220. #endif
  221. /*}}}  */
  222. /*{{{  STRRSTR_C*/
  223. char *strrstr (char *, char*);
  224. /*}}}  */
  225. /*{{{  KEYTAB_C*/
  226. #ifdef KEYTAB_C
  227. #define I_SIGNALS_C
  228. #endif
  229. /*}}}  */
  230.  
  231. #define os_init_args_read() init_amiga_post_arg()
  232. #define os_init_rc_read() init_amiga_post_rc()
  233. #define os_init() init_amiga_pre_arg(&argc, ((struct WBStartup **)&argv))
  234. #define open_shell popen
  235. #define close_shell pclose
  236. /*{{{  min*/
  237. #ifndef min
  238. #define min(a,b) ((a)<=(b)?(a):(b))
  239. #endif
  240. /*}}}  */
  241. /*}}}  */
  242. /*{{{  additional define for some modules*/
  243. /*{{{  INITRESET*/
  244. #ifdef INITRESET_C
  245. # define CONU_LIBRARY -1
  246. #endif
  247. /*}}}  */
  248. /*{{{  GETTK*/
  249. #ifdef GETTK_C
  250. #  undef signal
  251. #  define signal(a,b)  {}
  252. #  define chartest if (ch=='\0' || ch=='\n') ch=O_NOP;
  253. #endif
  254. /*}}}  */
  255. /*{{{  SCANNER*/
  256. #ifdef SCANNER_C
  257. #  define OS_USINGS  use_it ("AMIGA");
  258.   extern char *buffer_dir;
  259. #  define OS_VARS init_arexx_var();
  260.   extern void init_arexx_var(void);
  261. #endif
  262. /*}}}  */
  263. /*{{{  KEYBIND*/
  264. #ifdef KEYBIND_C
  265.   /*{{{  write binding to .origamibind*/
  266. #  define bnd_wr(bnd,kbd,name,code) \
  267.     fprintf(bnd,kbd==mouse_kbd?"%d|%-35.*sMouse: %c\n":"%d|%-35.*s%s\n", \
  268.                 kbd,strlen(name),name,code)
  269.   /*}}}  */
  270.   /*{{{  SORTCMD*/
  271. #  define SORTCMD "orisort >%s "
  272.   /*}}}  */
  273. #endif
  274. /*}}}  */
  275. /*{{{  ORIEDT*/
  276. #ifdef ORIEDT_C
  277. #  define BASIC_ELEMENTS    256   /* number of first element's block */
  278. #  define NEW_ELEMENT_LIMIT  16   /* minimum number of malloced      */
  279.                                   /* element's block.                */
  280.                                   /* if malloc cannot return a block */
  281.                                   /* of NEW_ELEMENT_LIMIT elements,  */
  282.                                   /* a `not enough memory' warning   */
  283.                                   /* appears!                        */
  284. #  define NEW_ELEMENT_MAX    64   /* maximum number of malloced      */
  285.                                   /* element's block (used if lines  */
  286.                                   /* are handled virtuell)           */
  287. #endif
  288. /*}}}  */
  289. /*{{{  FOLDFILLING*/
  290. #ifdef FOLDFILING_C
  291. #  define ORICORE_NAME "oricoreXXXXXXXX"
  292. #  define CHMOD_PRIVATE(f) chmod(f,S_IWRITE | S_IREAD)
  293. #endif
  294. /*}}}  */
  295. /*{{{  SET || PARSECOND || MAIN*/
  296. #if defined(SET_C) || defined(PARSECOND_C) || defined(MAIN_C)
  297. #  define SETPART 8
  298. #  define SETSIZE (256/SETPART)
  299. #endif
  300. /*}}}  */
  301. /*{{{  WRITEFOLDS*/
  302. #ifdef WRITEFOLDS_C
  303. #  undef fopen
  304. #  undef fclose
  305. #  define fopen(a,b) my_fopen(a,b)
  306. #  define fclose(a)  my_fclose(a)
  307. #endif
  308. /*}}}  */
  309. /*{{{  FIELDEDIT*/
  310. #ifdef FIELDEDIT_C
  311. # define MGR
  312. # define USER_SIGNAL
  313.   extern void user_signal_handle(void);
  314. #endif
  315. /*}}}  */
  316. /*{{{  LOOP*/
  317. #ifdef LOOP_C
  318. struct utsname { int i;};
  319. #endif
  320. /*}}}  */
  321. /*{{{  SCRBUFF*/
  322. #ifdef SCRBUFF_C
  323. #define EXT_SCRBUFF_ACCESS
  324. #define fl_overwrite my_fl_overwrite
  325. #endif
  326. /*}}}  */
  327. /*{{{  SCRBUFF || SCREEN*/
  328. #if defined (SCRBUFF_C) || defined (SCREEN_C)
  329. /*{{{  line_store struct*/
  330. struct line_store
  331.  {
  332.   int x;
  333.   int y;
  334.   int changed;
  335.   char *str;
  336.   int len;
  337.   int maxlen;
  338.  };
  339. /*}}}  */
  340. #endif
  341. /*}}}  */
  342. /*}}}  */
  343. /*{{{  prototypes of amiga files*/
  344. /*{{{  AMIGAMISC*/
  345. #ifndef AMIGA_MISC_C
  346. #  ifdef AREXX
  347.   extern char *portname;
  348.   struct RexxMsg *GetArexxMsg (void);
  349.   void ReplyARexxMsg(struct RexxMsg *,char *,long);
  350.   short SetARexxLastError(struct Message *,char *);
  351.   int handle_rexx (void);
  352. #  endif
  353.   FILE *my_fopen (char *,char *);
  354.   int my_fclose (FILE *);
  355.   int getpid (void);
  356.   void usleep (long);
  357.   void sleep (int);
  358.   void user_signal_handle (void);
  359.   void os_ext_handle (FILE *, int);
  360.   char *strerror(int);
  361.   char *handle_amiga_args(char *);
  362. #endif
  363. /*}}}  */
  364. /*{{{  INITRESET*/
  365. #ifndef INITRESET_C
  366.   /*{{{  MENU*/
  367. #  ifdef MENU
  368.   extern boolean menu_on;
  369.   extern struct Menu *menu_root;
  370. #  endif
  371.   /*}}}  */
  372.   /*{{{  AREXX*/
  373. #  ifdef AREXX
  374.   extern boolean arexx;
  375.   extern _AREXX *_arexx;
  376.   extern struct Library *RexxSysBase;
  377. #  endif
  378.   /*}}}  */
  379.   extern struct Library *IFFParseBase;
  380.   extern struct Screen *beep_screen;
  381.   extern struct Window *wind;
  382.   extern struct RastPort *rp;
  383.   extern short screenw,screenh,windx,windy,windw,windh,
  384.                height,mul_x,mul_y,off_y,off_y_base,init_wind;
  385.   extern boolean screen_yes;
  386.   extern struct MsgPort *mpp;
  387.   extern struct timerequest *tr;
  388.   extern ULONG my_signal;
  389.   extern char window_name[_POSIX_PATH_MAX+1];
  390.   /*{{{  only in Main*/
  391. #  ifdef MAIN_C
  392.   void init_amiga_pre_arg (int *argc, struct WBStartup **argv);
  393.   void init_amiga_post_arg (void);
  394.   void init_amiga_post_rc (void);
  395.   void reset_amiga (void);
  396. #  endif
  397.   /*}}}  */
  398. #endif
  399. /*}}}  */
  400. /*{{{  KEYBOARD*/
  401. #ifndef KEYBOARD_C
  402. #ifdef KEYS_H
  403.   extern TOKEN buffer_keys[buffer_keys_max];
  404. #endif
  405.   extern int key_buffer_max;
  406.   void scan_abort_key (void);
  407. #else
  408.   unsigned char cur_scr_char(int,int);
  409. #endif
  410. /*}}}  */
  411. /*{{{  SCREEN*/
  412. #ifndef SCREEN_C
  413.   void FlushOneLine (void);
  414.   int oputc (char ch);
  415.   int eputc (unsigned char ch);
  416.   int eputs (unsigned char *ptr);
  417. #endif
  418. /*}}}  */
  419. /*{{{  MISC*/
  420. #ifdef MISC_C
  421. #  define OS_FILEPROMPT 1
  422. #endif
  423. /*}}}  */
  424. /*{{{  SIGNALS*/
  425. #ifndef SIGNALS_C
  426.   extern boolean timer_running;
  427.   void alarm (int);
  428.   void sig_alarm_reached (int);
  429. #endif
  430. /*}}}  */
  431. /*}}}  */
  432. /*}}}  */
  433. #undef boolean
  434. #else
  435. /*{{{  dirfold*/
  436. #include <fcntl.h>
  437.  
  438. #define geteuid()    1
  439. #define getegid()    1
  440. #define getuid()    1
  441. #define getgid()    1
  442. #define gid_t        unsigned short
  443. #define uid_t        unsigned short
  444.  
  445. char buffer_dir[_POSIX_PATH_MAX]; /* used for getcwd */
  446. /*}}}  */
  447. #endif
  448. /*{{{  os version string*/
  449. #if defined(MAIN_C)||defined(KEYBIND_C)||defined(FOLDER) || defined(VIEW_MAIN_C)
  450. #ifdef ORIGAMI
  451. #define PROGNAME "Origami"
  452. #endif
  453. #ifdef KEYBIND
  454. #define PROGNAME "Keybind"
  455. #endif
  456. #ifdef FOLDER
  457. #define PROGNAME "Dirfold"
  458. #endif
  459. #ifdef VIEWRC
  460. #define PROGNAME "Viewrc"
  461. #endif
  462. #include <h/envvar_str.h>
  463. static char version_string_os_2_x_conform[]= "$VER: " PROGNAME " " MINOR_VERSION "." REVISION " (" __DATE__ ") Major Version " MAJOR_VERSION ;
  464. #endif
  465. #endif
  466. /*}}}  */
  467.